/*
 * Copyright (C) 2011 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.google.android.apps.mytracks.services.sensors.ant;

import com.google.android.maps.mytracks.R;

/**
 * A enum which stores static data about ANT sensors.
 *
 * @author Matthew Simmons
 */
public enum AntSensor {
  SENSOR_HEART_RATE (
      R.string.ant_heart_rate_sensor_id_key,
      Constants.ANT_DEVICE_TYPE_HRM),
  SENSOR_CADENCE (
      -1,
      Constants.ANT_DEVICE_TYPE_CADENCE),
  SENSOR_SPEED (
      -1,
      Constants.ANT_DEVICE_TYPE_SPEED),
  SENSOR_POWER (
      -1,
      Constants.ANT_DEVICE_TYPE_POWER);

  private static class Constants {
    public static byte ANT_DEVICE_TYPE_POWER = 11;
    public static byte ANT_DEVICE_TYPE_HRM = 120;
    public static byte ANT_DEVICE_TYPE_CADENCE = 122;
    public static byte ANT_DEVICE_TYPE_SPEED = 123;
  };

  private final int prefKey;
  private final byte deviceType;

  private AntSensor(int prefKey, byte deviceType) {
    this.prefKey = prefKey;
    this.deviceType = deviceType;
  }

  public int getPrefKey() {
    return prefKey;
  }

  public byte getDeviceType() {
    return deviceType;
  }

  public byte getChannelNumber() {
    // Each sensor needs to have its own channel number.  These numbers are
    // somewhat scarce, but not given the number of sensors we're using.  As
    // such, we can use the enum ordinals without needing to pack.
    return (byte) ordinal();
  }
}
